package com.ruoyi.garde.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.uuid.UUID;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.garde.mapper.TbGradeMapper;
import com.ruoyi.garde.domain.TbGrade;
import com.ruoyi.garde.service.ITbGradeService;

/**
 * 年级Service业务层处理
 *
 * @author hongyi
 * @date 2023-12-26
 */
@Service
public class TbGradeServiceImpl implements ITbGradeService
{
    @Autowired
    private TbGradeMapper tbGradeMapper;

    /**
     * 查询年级
     *
     * @param id 年级主键
     * @return 年级
     */
    @Override
    public TbGrade selectTbGradeById(String id)
    {
        return tbGradeMapper.selectTbGradeById(id);
    }

    @Override
    public TbGrade getTbGradeByCode(String code) {
        return tbGradeMapper.getTbGradeByCode(code);
    }

    @Override
    public TbGrade getTbGradeByName(String name) {
        return tbGradeMapper.getTbGradeByName(name);
    }

    /**
     * 查询年级列表
     *
     * @param tbGrade 年级
     * @return 年级
     */
    @Override
    public List<TbGrade> selectTbGradeList(TbGrade tbGrade)
    {
        return tbGradeMapper.selectTbGradeList(tbGrade);
    }

    /**
     * 新增年级
     *
     * @param tbGrade 年级
     * @return 结果
     */
    @Override
    public int insertTbGrade(TbGrade tbGrade)
    {
//        tbGrade.setCreateTime(DateUtils.getNowDate());
        tbGrade.setId(UUID.randomUUID().toString().replaceAll("-", ""));;
        return tbGradeMapper.insertTbGrade(tbGrade);
    }

    /**
     * 修改年级
     *
     * @param tbGrade 年级
     * @return 结果
     */
    @Override
    public int updateTbGrade(TbGrade tbGrade)
    {
        tbGrade.setUpdateTime(DateUtils.getNowDate());
        return tbGradeMapper.updateTbGrade(tbGrade);
    }

    /**
     * 批量删除年级
     *
     * @param ids 需要删除的年级主键
     * @return 结果
     */
    @Override
    public int deleteTbGradeByIds(String[] ids)
    {
        return tbGradeMapper.deleteTbGradeByIds(ids);
    }

    /**
     * 删除年级信息
     *
     * @param id 年级主键
     * @return 结果
     */
    @Override
    public int deleteTbGradeById(String id)
    {
        return tbGradeMapper.deleteTbGradeById(id);
    }
}
